#ifndef __WIN32WINDOW_H__
#define __WIN32WINDOW_H__

#include "WindowsInterface.h"	

class CWin32Window : public IWindow {
	public:
		HWND m_hWnd;
		
		CWin32Window() : m_hWnd( NULL ) {}
		virtual ~CWin32Window() {}
		
		HWND GetHWnd() const { return m_hWnd; }
		
		virtual bool CreateWnd( int width, int height, const TCHAR *title );
		virtual void MessageLoop();
		
	protected:
		
		//	virtual functions
		virtual BOOL PreCreateWindow( CREATESTRUCT& cs ) { return TRUE; }
		virtual int OnCreate( LPCREATESTRUCT lpCreateStruct );
		virtual void OnSize( UINT nType, int cx, int cy  ) {}
		virtual void OnPaint() {}
		virtual void OnClose() {}
		virtual void OnDestroy() { PostQuitMessage( 0 ); }
		virtual void OnIdle( long lCount ) {}
		virtual void OnTimer( UINT nIDEvent ) {}
		virtual void OnLButtonDown( UINT nFlags, int x, int y ) {}
		virtual void OnLButtonUp( UINT nFlags, int x, int y ) {}
		virtual void OnLButtonDblClk( UINT nFlags, int x, int y ) {}
		virtual void OnRButtonDown( UINT nFlags, int x, int y ) {}
		virtual void OnRButtonUp( UINT nFlags, int x, int y ) {}
		virtual void OnRButtonDblClk( UINT nFlags, int x, int y ) {}
		virtual void OnMButtonDown( UINT nFlags, int x, int y ) {}
		virtual void OnMButtonUp( UINT nFlags, int x, int y ) {}
		virtual void OnMButtonDblClk( UINT nFlags, int x, int y ) {}
		virtual void OnMouseMove( UINT nFlags, int x, int y ) {}
		virtual BOOL OnMouseWheel( UINT nFlags, short zDelta, int x, int y ) { return TRUE; }
		virtual BOOL OnCommand( WPARAM wParam, LPARAM lParam ) { return TRUE; }
		virtual void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) {}
		virtual void OnKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags ) {}
		virtual void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags ) {}
		
		// member functions
		UINT SetTimer( UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc = NULL ) 
		{return ::SetTimer( m_hWnd, nIDEvent, uElapse, lpTimerFunc ); }
		BOOL KillTimer( int nIDEvent ) { return ::KillTimer( m_hWnd, nIDEvent ); }
		BOOL DestroyWindow() { return ::DestroyWindow( m_hWnd ); }
		int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = _T( "Info" ), UINT nType = MB_OK ) 
		{ return ::MessageBox( m_hWnd, lpszText, lpszCaption, nType ); }
		HDC GetDC() { return ::GetDC( m_hWnd ); }
		HICON SetIcon( HICON hIcon, BOOL bBigIcon ) { return (HICON)::SendMessage( m_hWnd, WM_SETICON, bBigIcon, (LPARAM)hIcon ); }

		// static member functions
		static LRESULT CALLBACK MessageRouter( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
	
	private:

		LRESULT CALLBACK WndProc( UINT message, WPARAM wParam, LPARAM lParam );
};

#endif	//	__WIN32WINDOW_H__